<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="cc.woori.mobile.bean.*" %>
<%@ page import="cc.woori.mobile.PMF" %>
<%@ page import="javax.jdo.*" %>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form name="input" action="/admin/note/register" method="post">
    	<table>
          <tr>
	        <td>제목</td>
	        <td><input type="text" name="title" size="80"/></td>
	      </tr>
	      <tr>
	        <td>설명</td>
	        <td><TEXTAREA name="body" rows="10" cols="80"></TEXTAREA></td>
	      </tr>
	      <tr>
      		<td colspan="2"><input type="submit" value="등록" /></td>
      	</tr>
		</table>
    </form>
    <table>
    <tr>
    	<th>제목</th>
    	<th>내용</th>
    	<th>삭제</th>
    </tr>
    <%
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try{
    	Query query = pm.newQuery(NoteEntity.class);
		query.setOrdering("publishDate desc");
		query.setRange(0,30);
		
		List<NoteEntity> results = (List<NoteEntity>) query.execute();

	    for (NoteEntity e : results) {
	    %>
	    	<tr>
	    		<td>
	    			<!-- 제목  -->
	    			<%=e.getTitle()%> 
	    		</td>
	    		<td>
	    			<!--  내용 -->
	    			<%=e.getBody() %>
	    		</td>
	    		<td>
	    			<a href="/admin/modifyNotice.jsp?key=<%=KeyFactory.keyToString(e.getKey()) %>">수정</a>
	    		</td>
    			<td>
	    			<a href="/admin/note/modify?mode=delete&key=<%=KeyFactory.keyToString(e.getKey()) %>">삭제</a>
	    		</td>
	    	</tr>
	<%
	    }//end for
	}finally{
		if(pm != null){
			pm.close();
		}
	}
    %>
    </table>
    

</body>
</html>